home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 November / Chip Kasım 2000.iso / prog / kasim / 04 / setup.exe / frpdf095.tcl < prev    next >
Encoding:
Text File  |  2000-05-31  |  28.7 KB  |  869 lines

  1. #!/bin/s    
  2. # the next line restarts using wish \
  3. exec wish "$0" "$@"
  4.  
  5. # FreePDF -- 
  6. # This script calls GhostScript to convert the
  7. # PS (PostScript) input file into a PDF on Windows 9x.  
  8. #
  9. # Free PDF is used as part of 
  10. # a process.  This process enables one to Print to a special 
  11. # printer from any Windows application and 
  12. # create output files in the output folder. 
  13. # in a PDF (Adobe's Portable Document Format) file, 
  14. # which is viewable using 
  15. # Adobe's Acrobat product among other programs.
  16. #
  17. # Limitations:
  18. # This version is Now Beta and close to release.
  19. # It has the location for the GhostScript
  20. # executable as "C:\Aladdin\gs6.01\bin\gswin32c.exe" ,
  21. # and the location for the Acrobat Reader 
  22. # executable as 
  23. # "C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe" ,
  24. # These can be overriden by using the Config Screen
  25. # and clicking on the links for the files or by 
  26. # editting the file "FREEPDF.INI"
  27. # in the FreePDF Directory
  28. #
  29. # From version 0.28 on you have the 'Save PDF as' button
  30. # which allows you to place the output PDF file 
  31. # in whatever folder with whatever name you'd like. 
  32. # FreePDF will remember the folder and output name
  33. # from the last time it was used.
  34. #
  35. # This program requires 2 parameters.
  36. # The 1st is ignored as are any past the 2cnd.
  37. # The second is the only one used 
  38. # and should contain the full path and filename 
  39. # of the Input PS temporary file to be converted.
  40. # to a PDF.
  41. # This is fine as REDRUN handles this
  42. # Open the file 
  43. # C:\freepdf\dochtml\freepdf.htm for full details
  44. #
  45. # It is intended to be used in conjunction with
  46. #
  47. # RedMon (Printer port REDirection Monitor) 
  48. # from Ghostgum Software Pty Ltd.,
  49. # and GhostScript from Aladdin Enterprises.
  50. # The setup for this whole process is involved.
  51. # Open the file 
  52. # C:\freepdf\dochtml\freepdf.htm
  53. # in Internet explorer for full details
  54. #
  55. # FreePDF is distributed under the terms of the 
  56. # ALADDIN FREE PUBLIC LICENCE
  57. # and is Copyright (C) 2000, BMRWare. All rights reserved.
  58. # See the ASCII file license in this directory for details.
  59. # Need "Program handles Output" on RPT1 setup
  60. #
  61. # RedMon (Printer port REDirection Monitor) 
  62. # is Copyright (C) 1997-1999, Ghostgum Software Pty Ltd.
  63. # GhostScript is 
  64. # Copyright (C) 1994, 1995, 1997, 1998 Aladdin Enterprises,
  65. #   Menlo Park, California, U.S.A. All rights reserved.
  66. # RCS: @(#) $Id: FreePDF,v 0.95 2000/05/31 18:23:30 Rhodes Exp $
  67.  
  68. #----------------------------------------------------------------
  69. # BEFORE RELEASE MAKE SURE TO DO THE FOLLOWING
  70. #----------------------------------------------------------------
  71. # 1 - Set the 'testing' variable to 0
  72. #----------------------------------------------------------------
  73.  
  74. # Version Notes
  75. #+----+----------+------------------------------------------------------------+
  76. #+Ver |MM/DD/YYYY|Description                                                 +
  77. #+----+----------+------------------------------------------------------------+
  78. #+0.15|04/01/2000| First version just calls GhostScript                       +
  79. #+----+----------+------------------------------------------------------------+
  80. #+0.20|04/02/2000| Working on Parm madness Need Parm 2!                       +
  81. #+----+----------+------------------------------------------------------------+
  82. #+0.21|04/02/2000| Make call to gswin32.exe Writes "C:\WINDOWS\\Start Menu    +
  83. #+    |          | Writes "C:\WINDOWS\Start Menu\Output.pdf'                  +
  84. #+----+----------+------------------------------------------------------------+
  85. #+0.22|04/03/2000| Variablizing the hardcoded paths and program names         +                       
  86. #+    |          | Added buttons to View Output and Exit                      +
  87. #+    |          | Next will make them configurable                           +
  88. #+----+----------+------------------------------------------------------------+
  89. #+0.23|04/02/2000| Added See Command Button moved screen text around          +
  90. #+----+----------+------------------------------------------------------------+
  91. #+0.24|04/04/2000| Removed Acrobat save as tip and added adobe coppyright     +
  92. #+----+----------+------------------------------------------------------------+
  93. #+0.27|04/05/2000| Added Make PDF, About and disabled Configure buttons       +
  94. #+----+----------+------------------------------------------------------------+
  95. #+0.28|04/06/2000| Added ini file variables, Enabled Configure and            +
  96. #+    |          | renamed 'Make pdf' to 'Save PDF as..' buttons              +
  97. #+----+----------+------------------------------------------------------------+
  98. #+0.30|04/07/2000| Added check that ini file exits and create if needed       +
  99. #+    |          | FreePDF also now saves and uses the settings from last time+
  100. #+----+----------+------------------------------------------------------------+
  101. #+0.31|04/23/2000| Changed defaults for Aladdin directory                     +
  102. #+----+----------+------------------------------------------------------------+
  103. #+0.32|04/24/2000| Revamped Config Screen!  Added Browse Button in Config     +
  104. #+    |          | for Finding GhostScript PDF Converter and PDF Viewer!      +
  105. #+    |          | Added Automatic Copy to Clipboard of PDF path and name     +
  106. #+    |          | of the created PDF upon success                            +
  107. #+    |          | Added Open PS for selecting PS file when bad parms passed  +
  108. #+----+----------+------------------------------------------------------------+
  109. #+0.33|05/12/2000| Changed Title in Open file Dialog box for pdfViewer        +
  110. #+----+----------+------------------------------------------------------------+
  111. #+0.87|05/19/2000| First Beta Release  Small bugs Squashed!                   +
  112. #+----+----------+------------------------------------------------------------+
  113. #+0.94|05/26/2000| Added Checkbox Options to Config screen for                +
  114. #+    |          | "Show Save as Dialog Automatically",                       +
  115. #+    |          | "Launch PDF Viewer Automatically After Conversion" and     +
  116. #+    |          | "Auto-Exit FreePDF After PDFViewer Close"                  +
  117. #+    |          |About box is now real window also instead of just Dialog Box+
  118. #+----+----------+------------------------------------------------------------+
  119. #+0.95|05/31/2000| Added new Checkbox Options to Config screen for            +
  120. #+    |          | "Remind to close PDFViewer                                 +
  121. #+----+----------+------------------------------------------------------------+
  122. #
  123. # List of things to do, future plans and ideas
  124. #+----------------------------------------------------------------------------+
  125. #  Check content of file for PS header and Abort if absent
  126. #  Log File
  127. #  Configurable Default Output Directory
  128. #  Configurable Default Output File Name
  129. #  'Save as..' Dialog to name the output
  130. #  Right Click 'Convert to PDF' Explorer Integration
  131. #  Optionally on Completion:
  132. #    Run Acrobat or GhostView to View the Output 
  133. #    Zip 'output.pdf' 
  134. #  Batch mode with
  135. #    Watched Input and Output Folders
  136. #    Delete Input PS file after Successful PDF Creation Option
  137. #  Update Checker and Downloader
  138. #  Minimize to System Tray?
  139. #  Installer and UNInstaller
  140. #+----------------------------------------------------------------------------+
  141.  
  142. # Create the window ('.' is the main window, 
  143. #   'FreePDF v n.nn' is the title)
  144. #----------------------------------------------------------------
  145.  set pgmName "FreePDF"
  146.  set ver "v0.95 Beta"
  147.  set asofdate "05/31/2000"
  148.  wm title . "$pgmName $ver"
  149. # toplevel .
  150.  
  151. #----------------------------------------------------------------
  152. # Testing Variable  
  153. #----------------------------------------------------------------
  154. # IMPORTANT SET TO ZERO BEFORE RELEASE!!!
  155. #----------------------------------------------------------------
  156. # 0 for release 
  157. #    - Suppresses both testing messages 
  158. #    - Suppresses 'package require' commands.
  159. #    FREEWRAP provides this and does not work if the
  160. #    the 'package require' command is issued!
  161. # 1 for testing (Like production)
  162. #    - no messages
  163. # 2 for testing 
  164. #    - all messages turned on 
  165. #    - does issues package require command
  166. #----------------------------------------------------------------
  167. #  Note: Copies of these variables may be retrieved by procedures 
  168. #  using the 'upvar" command
  169. #----------------------------------------------------------------
  170.  eval destroy [winfo child .]
  171.  set testing 0
  172.  set convertflag 0
  173.  set changeflag 0
  174.  set errorflag 0
  175.  
  176. # RedRun actually gives us the name of the file in the second
  177. # parameter!  Don't know why so instead of 0 (first parameter) 
  178. # we want 1 (second parameter) in lindex!
  179.  set parm1 [lindex $argv 1]
  180.  
  181. # You can uncomment the set just below to see the actual 
  182. # parameter list sent by RedRun
  183. # set parm1 $argv
  184.  
  185. # FreePDF Variables
  186. #----------------------------------------------------------------
  187. # These are default values in case freepdf.ini doesn't
  188. # exist.  If it does exist the incoming values from the ini file
  189. # will overlay these
  190.   set pdfOutFile "Output.pdf"
  191.   set pdfIniFile "freepdf.ini"
  192.   set pdfConverter "C:/Aladdin/gs6.01/bin/gswin32c.exe"
  193.   set pdfViewer "C:/Program Files/Adobe/Acrobat 4.0/Reader/AcroRd32.exe"
  194.  
  195. # Dynamically retrieve pdfOutDir
  196. #----------------------------------------------------------------
  197.   set pdfOutDir         [file dirname [info nameofexecutable]]/
  198.   set pdfIniFile        $pdfOutDir$pdfIniFile
  199.   set pdfSaveAsImmed    0
  200.   set pdfAutoView       1
  201.   set pdfRemindPdfView  1
  202.   set pdfQuickExit      0
  203.  
  204. #*****************************************************************
  205. #*****************************************************************
  206. # U S E R   D E F I N E D    PROCEDURES FOLLOW
  207. #*****************************************************************
  208. #*****************************************************************
  209.  
  210. #-----------------------------------------------------------------
  211. # OpenPS - Gets the name of the input PostScript File
  212. #          Only is shown if no parameter were passed which they
  213. #          should be!
  214. #-----------------------------------------------------------------
  215. proc OpenPS {  } {
  216.   global pgmName  \
  217.          ver      \
  218.          testing  \
  219.          errorflag\
  220.          text1    \
  221.          parm1
  222.  
  223.   set psDir "C:/"
  224.  
  225.     #   Type names        Extension(s)    Mac File Type(s)
  226.     #
  227.     #---------------------------------------------------------
  228.     set types {
  229.     {"PS files"        {.ps }    }
  230.     {"All files"        *}
  231.               }
  232.  
  233.   set file [tk_getOpenFile\
  234.             -filetypes $types\
  235.             -initialdir $psDir\
  236.             -defaultextension .ps\
  237.             -parent .\
  238.             -title "Where is the PostScript Input?"
  239.            ]
  240.   if [string compare $file ""] {
  241.     set parm1 $file
  242.     set text1 "Input file to be converted to PDF is \n<$parm1>\n
  243. Click the 'Save PDF as..' button, to create your PDF"  
  244.     set errorflag 0
  245.   }
  246. }
  247.  
  248. #-----------------------------------------------------------------
  249. # SaveAs - Get Name for Output file
  250. #-----------------------------------------------------------------
  251. proc SaveAs {  } {
  252.   global pgmName     \
  253.          ver         \
  254.          testing     \
  255.          pdfOutDir   \
  256.          pdfOutFile  \
  257.          pdfConverter\
  258.          pdfViewer   \
  259.          changeflag
  260.  
  261.     #   Type names        Extension(s)    Mac File Type(s)
  262.     #
  263.     #---------------------------------------------------------
  264.     set types {
  265.     {"PDF files"        {.pdf }    }
  266.     {"All files"        *}
  267.               }
  268.   set file [tk_getSaveFile\
  269.             -filetypes $types\
  270.             -initialdir $pdfOutDir\
  271.             -initialfile $pdfOutFile\
  272.             -defaultextension .pdf\
  273.             -parent .\
  274.             -title "$pgmName - Save PDF as "
  275.            ]
  276.   if [string compare $file ""] {
  277.     set pdfOutDir  [file dirname $file]/
  278.     set pdfOutFile [file tail $file]
  279.     set changeflag 1
  280.   } else {
  281.     set changeflag 0
  282.   }
  283. }
  284.  
  285. #-----------------------------------------------------------------
  286. # MakePDF - Does 'Save as' and calls GhostScript to convert to pdf
  287. #-----------------------------------------------------------------
  288. proc MakePDF {  } {
  289. # remember to check for filein's existence
  290. # and that gswin32 exists!
  291.    global pgmName     \
  292.           ver         \
  293.           testing     \
  294.           pdfConverter\
  295.           pdfViewer   \
  296.           pdfOutDir   \
  297.           pdfOutFile  \
  298.           text1       \
  299.           text2       \
  300.           parm1       \
  301.           changeflag  \
  302.           pdfAutoView
  303.  
  304.  
  305.   if [expr $testing < 1] {
  306.      set oldfile $pdfOutDir$pdfOutFile
  307.      SaveAs
  308. #      changeflag will be 0 if the user hit 'Cancel' in 'Save PDF as'!
  309. #      changeflag will be 1 if the user hit 'Ok'     in 'Save PDF as'!
  310.      if [expr $changeflag] {
  311.        WriteIni
  312.        update
  313.        exec $pdfConverter -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite\
  314. -sOutputFile=$pdfOutDir$pdfOutFile  -c save pop -f $parm1
  315.        set text1 "Your PDF is called $pdfOutFile in the\n$pdfOutDir Folder." 
  316.        set text2 "Click on The 'View PDF' button Above
  317. To Open it in Acrobat Reader.
  318. "
  319. #*****************************************************************
  320. #**     - v0.31 added copy to clipboard of PDF path and name
  321.        clipboard clear
  322.        clipboard append $pdfOutDir$pdfOutFile
  323. #*****************************************************************
  324.        if {$pdfAutoView > 0} {
  325.          update
  326.          CallPdfViewer
  327.        }
  328.      }
  329.    }
  330. }
  331.    
  332. #-----------------------------------------------------------------
  333. # CallPdfViewer - Just Views the PDF output 
  334. #-----------------------------------------------------------------
  335. proc CallPdfViewer {  } {
  336.   global pgmName          \
  337.          ver              \
  338.          testing          \
  339.          pdfRemindPdfView \
  340.          pdfQuickExit     \
  341.          pdfViewer        \
  342.          pdfOutDir        \
  343.          pdfOutFile
  344.  
  345.  
  346.   if {$pdfRemindPdfView > 0} {
  347.     tk_messageBox\
  348.         -icon info -type ok \
  349.         -title "$pgmName" \
  350.         -message \
  351. "Make sure you Remember to Close 
  352. the PDFViewer! Don't just minimize it!"
  353.     }
  354.  
  355.   exec "$pdfViewer" $pdfOutDir$pdfOutFile
  356.  
  357.   if {$pdfQuickExit > 0} {
  358.     update
  359.     destroy .
  360.   }
  361.  
  362. }
  363.  
  364. #-----------------------------------------------------------------
  365. # ReadIni - Read Ini File and set options
  366. #-----------------------------------------------------------------
  367. proc ReadIni {  } {
  368.   global pgmName       \
  369.          ver           \
  370.          testing       \
  371.          pdfOutDir     \
  372.          pdfOutFile    \
  373.          pdfIniFile    \
  374.          pdfConverter  \
  375.          pdfViewer     \
  376.          pdfSaveAsImmed\
  377.          pdfAutoView   \
  378.          pdfQuickExit  \
  379.          pdfRemindPdfView
  380.  
  381.   set existsFlag [file exists $pdfIniFile]
  382. ##  tk_messageBox -icon info -type ok -title "$pgmName $ver ReadIni" \
  383. ##       -message "existsFlag is $existsFlag"
  384.   if  {$existsFlag > 0} \
  385.   {
  386.     # Read pdfIniFile
  387.     set read ""
  388.     set readini [open $pdfIniFile r]
  389.     while {[gets $readini read] > -1} {
  390.       set l [string length $read]
  391.       set i [string first = $read]
  392.       if {$i >= 0}  \
  393.        {
  394.         set varname  [string range $read 0 [expr $i-1] ]
  395.         set varvalue [string range $read [expr $i+1]  $l]
  396. ##        tk_messageBox -icon info -type ok -title "$pgmName $ver Configure" \
  397. ##          -message "$pgmName $ver\t line read was\n $read\nvarname is \t$varname\nvarvalue is \t$varvalue\n"
  398.         switch $varname\
  399.             {
  400.               {pdfOutDir}
  401.                 {set pdfOutDir $varvalue
  402.                 }
  403.               {pdfOutFile}
  404.                 {set pdfOutFile $varvalue
  405.                 }
  406.               {pdfConverter}
  407.                 {set pdfConverter $varvalue
  408.                 }
  409.               {pdfViewer}
  410.                 {set pdfViewer $varvalue
  411.                 }
  412.               {pdfSaveAsImmed}
  413.                 {set pdfSaveAsImmed $varvalue
  414.                 }
  415.               {pdfAutoView}
  416.                 {set pdfAutoView $varvalue
  417.                 }
  418.               {pdfQuickExit}
  419.                 {set pdfQuickExit $varvalue
  420.                 }
  421.               {pdfRemindPdfView}
  422.                 {set pdfRemindPdfView $varvalue
  423.                 }
  424.  
  425.             }  ;# End Switch
  426.        }  ;# End if
  427.     }
  428.     close $readini
  429.   } else {
  430. ##      tk_messageBox -icon info -type ok -title "$pgmName $ver ReadPdfIni" \
  431. ##         -message "$pgmName - ReadpdfIni pdfIniFile \n$pdfIniFile\n Not found "
  432.       WriteIni 
  433.   } 
  434.  
  435.  
  436. #-----------------------------------------------------------------
  437. # WriteIni - Writes the FreePDF variables to ini file
  438. #-----------------------------------------------------------------
  439. proc WriteIni {  } {
  440.   global pgmName       \
  441.          ver           \
  442.          testing       \
  443.          pdfOutDir     \
  444.          pdfOutFile    \
  445.          pdfIniFile    \
  446.          pdfConverter  \
  447.          pdfViewer     \
  448.          pdfSaveAsImmed\
  449.          pdfAutoView   \
  450.          pdfQuickExit  \
  451.          pdfRemindPdfView
  452.  
  453. # Write pdfIniFile
  454. set writeini [open $pdfIniFile w]
  455. puts $writeini "<freepdf.ini>"
  456. puts $writeini "pdfOutDir=$pdfOutDir"
  457. puts $writeini "pdfOutFile=$pdfOutFile"
  458. puts $writeini "pdfConverter=$pdfConverter"
  459. puts $writeini "pdfViewer=$pdfViewer"
  460. puts $writeini "pdfSaveAsImmed=$pdfSaveAsImmed"
  461. puts $writeini "pdfAutoView=$pdfAutoView"
  462. puts $writeini "pdfRemindPdfView=$pdfRemindPdfView"
  463. puts $writeini "pdfQuickExit=$pdfQuickExit"
  464. close $writeini
  465. }
  466.  
  467. #-----------------------------------------------------------------
  468. # Configure - Sets paths and executable names
  469. #-----------------------------------------------------------------
  470. proc Configure {  } {
  471.   global pgmName          \
  472.          ver              \
  473.          testing          \
  474.          pdfOutDir        \
  475.          pdfOutFile       \
  476.          pdfIniFile       \
  477.          pdfConverter     \
  478.          pdfViewer        \
  479.          pdfSaveAsImmed   \
  480.          pdfAutoView      \
  481.          pdfQuickExit     \
  482.          pdfRemindPdfView \
  483.          asofdate
  484.  
  485.   WriteIni
  486.  
  487.   set w .config
  488.   catch {destroy $w}
  489.   toplevel $w
  490.   wm title $w "$pgmName Configure"
  491.  
  492.   text $w.text -yscrollcommand "$w.scroll set" -setgrid true \
  493.      -width 54 -height 34  -wrap word -background #C0C0C0
  494.   scrollbar $w.scroll -command "$w.text yview"
  495.   pack $w.scroll -side right -fill y
  496.   pack $w.text -expand yes -fill both
  497.  
  498. #    Set up display styles.
  499.  
  500. #  set bold "-foreground #ffff66 -relief raised -borderwidth 1 -underline 0"
  501.   set bold   "-foreground #005000 -relief flat -underline 1 -borderwidth 0"
  502.   set normal "-foreground #0000ff -relief flat -underline 1"
  503.  
  504.   foreach tag {d1 d2 d3} {
  505.     $w.text tag configure $tag -underline on -foreground #0000ff
  506.   }
  507. #     Add text to widget.
  508.  
  509.   checkbutton $w.saveAsImmed -text "Show Save as Dialog Automatically"\
  510.                     -variable pdfSaveAsImmed -relief flat -command "WriteIni"
  511.   checkbutton $w.autoView    -text "Launch PDF Viewer Automatically After Conversion"\
  512.                     -variable pdfAutoView    -relief flat -command "WriteIni"
  513.   checkbutton $w.remindPdfView  -text "Remind me to Close PDFViewer     "\
  514.                     -variable pdfRemindPdfView  -relief flat -command "WriteIni"
  515.   checkbutton $w.quickExit   -text "Auto-Exit FreePDF After PDFViewer Close"\
  516.                     -variable pdfQuickExit   -relief flat -command "WriteIni"
  517.  
  518. # --- Do the insert into the text -----
  519.   $w.text insert 0.0 \
  520. "$pgmName $ver\tCurrent as of $asofdate \n
  521. Greetings from the ZipGuy! \n
  522. Current settings:
  523. File executed:\t'[info nameofexecutable]'
  524. pdfIniFile: \t'$pdfIniFile'
  525. pdfOutDir:  \t'$pdfOutDir'
  526. pdfOutFile: \t'$pdfOutFile'
  527.  
  528.  
  529. Click on The Items below to change them!"
  530.  
  531.   $w.text insert end \n\n
  532.   $w.text insert end \
  533. "pdfConverter\n'"
  534.   $w.text insert end \
  535. "$pdfConverter" d1
  536.   $w.text insert end '\n\n
  537.  
  538.   $w.text insert end \
  539. "pdfViewer   \n'"
  540.   $w.text insert end \
  541. "$pdfViewer" d2 
  542.   $w.text insert end '\n\n
  543.  
  544.   $w.text window create end -window $w.saveAsImmed 
  545.   $w.text window create end -window $w.autoView
  546.   $w.text window create end -window $w.remindPdfView
  547.   $w.text window create end -window $w.quickExit
  548.   $w.text insert end \n
  549.  
  550.   $w.text insert end \n\t\t\t
  551.   $w.text insert end \
  552. "Exit Config" d3
  553.  
  554.   $w.text insert end "\n
  555. \t\t       Zipguy says 'Enjoy!' ;-)"
  556.  
  557.  
  558.   foreach tag {d1 d2 d3} {
  559.     $w.text tag bind $tag <Any-Enter> "$w.text tag configure $tag $bold"
  560.     $w.text tag bind $tag <Any-Leave> "$w.text tag configure $tag $normal"
  561.   }
  562.  
  563.   $w.text tag bind d1 <1> {ConfigurepdfConverter}
  564.   $w.text tag bind d2 <1> {ConfigurepdfViewer}
  565.   $w.text tag bind d3 <1> "destroy $w"
  566.  
  567.  
  568.   $w.text mark set insert 0.0
  569.   $w.text configure -state disabled
  570.  
  571. }
  572.  
  573. #-----------------------------------------------------------------
  574. # ConfigurepdfConverter - Sets paths and executable name 
  575. #                         of pdfConverter
  576. #-----------------------------------------------------------------
  577. proc ConfigurepdfConverter {  } {
  578.   global pgmName     \
  579.          ver         \
  580.          testing     \
  581.          pdfConverter
  582.  
  583.   set gsConverterDir  [file dirname $pdfConverter]/
  584.   set gsConverterFile [file tail $pdfConverter]
  585.  
  586.     #   Type names        Extension(s)    Mac File Type(s)
  587.     #
  588.     #---------------------------------------------------------
  589.     set types {
  590.     {"EXE files"        {.exe }    }
  591.     {"All files"        *}
  592.               }
  593.  
  594.  
  595.   set file [tk_getOpenFile\
  596.             -filetypes $types\
  597.             -initialdir $gsConverterDir\
  598.             -initialfile $gsConverterFile\
  599.             -defaultextension .exe\
  600.             -parent .config\
  601.             -title "Locate 'gswin32c.exe' - Ghostscript Executable"
  602.            ]
  603.   if [string compare $file ""] {
  604.     set pdfConverter $file
  605.     WriteIni
  606.     destroy .config
  607.   } else {
  608.   }
  609. }
  610.  
  611.  
  612. #-----------------------------------------------------------------
  613. # ConfigurepdfViewer - Sets paths and executable name 
  614. #                      of pdfViewer
  615. #-----------------------------------------------------------------
  616. proc ConfigurepdfViewer {  } {
  617.   global pgmName  \
  618.          ver      \
  619.          testing  \
  620.          pdfViewer
  621.  
  622.   set pdfViewerDir  [file dirname $pdfViewer]/
  623.   set pdfViewerFile [file tail $pdfViewer]
  624.  
  625.     #   Type names        Extension(s)    Mac File Type(s)
  626.     #
  627.     #---------------------------------------------------------
  628.     set types {
  629.     {"EXE files"        {.exe }    }
  630.     {"All files"        *}
  631.               }
  632.  
  633.   set file [tk_getOpenFile\
  634.             -filetypes $types\
  635.             -initialdir $pdfViewerDir\
  636.             -initialfile $pdfViewerFile\
  637.             -defaultextension .exe\
  638.             -parent .config\
  639.             -title "Locate 'AcroRd32.exe' - PDFViewer Executable"
  640.            ]
  641.   if [string compare $file ""] {
  642.     set pdfViewer $file
  643.     WriteIni
  644.     destroy .config
  645.   } else {
  646.   }
  647. }
  648.  
  649. #-----------------------------------------------------------------
  650. # SeeCommand -Shows the command issued to GhostScript 
  651. #-----------------------------------------------------------------
  652. proc SeeCommand {  } {
  653.   global pgmName     \
  654.          ver         \
  655.          testing     \
  656.          pdfConverter\
  657.          pdfOutDir   \
  658.          pdfOutFile  \
  659.          parm1       \
  660.  
  661.   tk_messageBox\
  662.       -icon info -type ok \
  663.       -title "$pgmName $ver" \
  664.       -message \
  665.                   "$pgmName $ver - Command issused to convert PS to PDF was: 
  666. $pdfConverter
  667. -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -c save pop
  668. -sOutputFile='$pdfOutDir$pdfOutFile' 
  669. -f $parm1 \n
  670. (Aren't You Glad you didn't have to type it in?)
  671. If you're curious, see the GhostScript Documentation 
  672. for what all those wacky switches do.
  673.  
  674. PDF (Portable Doument Format) is 
  675. Copyright ⌐2000 Adobe Systems Incorporated."
  676. }
  677.  
  678.  
  679.  
  680. #-----------------------------------------------------------------
  681. # About - Just Displays the About box - FreePDF information
  682. #-----------------------------------------------------------------
  683. proc About {  } {
  684.   global pgmName     \
  685.          ver         \
  686.          testing     \
  687.          pdfOutDir   \
  688.          pdfOutFile  \
  689.          pdfConverter\
  690.          pdfViewer   \
  691.          asofdate
  692.  
  693.  
  694.  
  695.   set w .about
  696.   catch {destroy $w}
  697.   toplevel $w
  698.   wm title $w "$pgmName $ver About"
  699.  
  700.   text $w.text -yscrollcommand "$w.scroll set" -setgrid true \
  701.      -width 70 -height 25 -wrap word -background #C0C0C0
  702.   scrollbar $w.scroll -command "$w.text yview"
  703.   pack $w.scroll -side right -fill y
  704.   pack $w.text -expand yes -fill both
  705.  
  706. #    Set up display styles.
  707.  
  708. #  set bold "-foreground #ffff66 -relief raised -borderwidth 1 -underline 0"
  709.   set bold   "-foreground #005000 -relief flat -underline 1 -borderwidth 0"
  710.   set normal "-foreground #0000ff -relief flat -underline 1"
  711.  
  712.   foreach tag {d1 d2 d3} {
  713.     $w.text tag configure $tag -underline on -foreground #0000ff
  714.   }
  715. #     Add text to widget.
  716.  
  717. # --- Do the insert into the text -----
  718.   $w.text insert 0.0 \
  719. "Recent News:
  720. v0.95 05/31/2000 Added Another Checkbox Option to Config screen for
  721.                  'Remind me to Close PDFViewer' Default yes                       
  722. v0.94 05/26/2000 Added Checkbox Options to Config screen for Default no for all these
  723.                  'Show Save as Dialog Automatically',                        
  724.                  'Launch PDF Viewer Automatically After Conversion' and              
  725.                  'Exit FreePDF After PDFViewer Close' 
  726.                  About box is now a real window also instead of just Dialog Box
  727. v0.88 05/26/2000 Code Cleanup                                         
  728. v0.87 05/19/2000 First Beta Release. Small bugs Squashed!                                         
  729.  
  730. Still Working on the Update checker.. 
  731. For now look for the latest version yourself at
  732. \thttp://over.to/freepdf. 
  733.  
  734. Hope you like it! 
  735. E-Mail Feedback Comments to: freepdf@over.to
  736.  
  737. $pgmName is Copyright ⌐ 2000, BMRWare. All rights reserved.
  738. PDF (Portable Doument Format) is Copyright ⌐2000 Adobe Systems Incorporated.
  739. "
  740.   $w.text insert end "\n
  741. \t\t       Zipguy says 'Enjoy!' ;-)"
  742.  
  743.   button $w.exit\
  744.      -text "Exit"\
  745.      -command "destroy .about" -padx 0 -pady 0  
  746. ####  button $w.homepage\
  747. ####     -text "Homepage"\
  748. ####     -command "exec C://Progra~1//Intern~1//IEXPLORE.EXE http://over.to/freepdf" -padx 0 -pady 0  
  749. ####  pack $w.homepage    -side left -expand 1
  750.   pack $w.exit        -side left -expand 1
  751.  
  752.  
  753. }
  754.  
  755.  
  756.  
  757. #*****************************************************************
  758. #*****************************************************************
  759. #*****************************************************************
  760. # START OF MAIN CODE
  761. #*****************************************************************
  762. #*****************************************************************
  763. #*****************************************************************
  764.  
  765.    frame .buttons -relief raised -borderwidth 1
  766.    set f .buttons
  767.    pack $f\
  768.      -side top -fill x -pady 0m
  769. #  Want 2 paramters 
  770.  
  771. #   ----------------------------------------------------------------
  772. #   Create the View PDF, Show Command, 
  773. #   Configure, About and Exit Button
  774. #   ----------------------------------------------------------------
  775.     button $f.makePdf\
  776.        -text "Save PDF as.." \
  777.        -command "MakePDF" -padx 0 -pady 0
  778.     button $f.viewPdf\
  779.        -text "View PDF" \
  780.        -command "CallPdfViewer" -padx 0 -pady 0
  781.     button $f.configure\
  782.        -text "Configure" \
  783.        -command "Configure" -padx 0 -pady 0
  784.     button $f.seeCommand\
  785.        -text "GS Command"\
  786.        -command "SeeCommand" -padx 0 -pady 0
  787.     button $f.exit\
  788.        -text "Exit"\
  789.        -command "destroy ." -padx 0 -pady 0  
  790.     button $f.about\
  791.        -text "About"\
  792.        -command "About" -padx 0 -pady 0
  793.     pack $f.makePdf     -side left -expand 1
  794.     pack $f.viewPdf     -side left -expand 1
  795.     pack $f.configure   -side left -expand 1
  796.     pack $f.seeCommand  -side left -expand 1
  797.     pack $f.about       -side left -expand 1
  798.     pack $f.exit        -side left -expand 1
  799.  
  800. #   ----------------------------------------------------------------
  801. #   Create the Screen Text
  802. #   ----------------------------------------------------------------
  803.     frame .ftxt -relief sunken
  804.     frame .ftxt.ftxt1 
  805.     set f .ftxt.ftxt1
  806.     pack $f\
  807.        -side top -fill x -pady 0m
  808.     label $f.txtFile \
  809.        -textvariable text1 \
  810.        -anchor w  -justify left
  811.     set text1 "Input file to be converted to PDF is \n<$parm1>\n
  812. Click the 'Save PDF as..' button, to create your PDF"  
  813.     pack $f.txtFile\
  814.        -side left
  815.  
  816.     frame .ftxt.ftxt2 
  817.     set f .ftxt.ftxt2
  818.     pack $f\
  819.        -side top -fill x -pady 0m
  820.     label $f.txtButtonExp \
  821.        -textvariable text2 \
  822.        -anchor w -justify left
  823.     set text2 ""
  824.     pack $f.txtButtonExp\
  825.        -side left
  826.     pack $f\
  827.        -fill x -padx 0 -pady 0
  828.     pack .ftxt\
  829.        -side left
  830. #    if [expr $testing < 1] {
  831. #    } ;# End if
  832.  
  833.  if [expr $argc < 2] {
  834. #     getting here means not enough parms passed!
  835.     set errorflag         1
  836.     set pdfSaveAsImmed    0
  837.     set pdfAutoView       1
  838.     set pdfRemindPdfView  1
  839.     set pdfQuickExit      0
  840.     WriteIni
  841.     frame .ftxt.fparm 
  842.     set f .ftxt.fparm
  843.     label $f.labbad -text "$pgmName $ver - Error!
  844. Less than 2 Parameters Recieved!
  845. FreePDF Received the following - <$argv>\n
  846. Use the 'Open PS' button below to specify input PostScript file!"\
  847.         -anchor w 
  848.     pack $f.labbad\
  849.         -side top
  850.  
  851.     button $f.openPS\
  852.        -text "Pick Input PS" -command "OpenPS" -padx 0 -pady 0
  853.     pack $f.openPS -side bottom -expand 1
  854.     pack $f \
  855.         -fill x -padx 0 -pady 0
  856.  } 
  857.  
  858.     if {$errorflag < 1} {
  859.       ReadIni
  860.       if {$pdfSaveAsImmed > 0} {
  861.         update
  862.         MakePDF
  863.       }
  864.     }  
  865.     
  866.  
  867.